package ads.remote;

import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.List;

import ads.exception.PlayingGameException;
import ads.util.GameInfo;
import ads.util.PlayerInfo;
import at.falb.games.alcatraz.api.Player;

public interface ServerInterface extends Remote {
	/**
	 * A client calls this method to register on the server.
	 * 
	 * @param username
	 * @param clentStub
	 */
	public void register(Player player, ClientInterface clientStub)
			throws RemoteException,PlayingGameException;

	/**
	 * A client can create a new game with the number of players she wants to
	 * play with.
	 * 
	 * @param player
	 * @param countOfPlayers
	 */
	public GameInfo createGame(Player player, int countOfPlayers)
			throws RemoteException,PlayingGameException;

	/**
	 * This method lists all the games created on the server.
	 * 
	 * @return
	 */
	public List<GameInfo> listAllGames() throws RemoteException;

	/**
	 * A client can join a game with GameID id.
	 * 
	 * @param player
	 * @param gameid
	 */
	public GameInfo joinGame(PlayerInfo player, Integer gameid) throws RemoteException,PlayingGameException;

	
	/**
	 * This method is called by a client after it gets disconnected during a
	 * game.
	 * 
	 * @param player
	 */
	public void relogin(Player player, ClientInterface clientStub) throws RemoteException,PlayingGameException;

	/**
	 * A client logs out using the logout method.
	 * 
	 * @param player
	 */
	public void logout(PlayerInfo player) throws RemoteException;
	
	/**
	 * 
	 * Client requests server to start recovery.
	 * 
	 * @param stub
	 * @throws RemoteException
	 */
	public void requestRecovery(PlayerInfo pi) throws RemoteException;

}
